#include<cstdio>//uncle-lu
#include<cstring>
#include<algorithm>

int line[110], F[110][110], J[110][110];
char t[110];
int n;

int main()
{
	scanf("%d\n", &n);
	for (int i = 1; i <= n; i++) 
	{
		scanf("%c %d ", &t[i], &line[i]);
		t[i+n] = t[i];
		line[i+n] = line[i];
	}

	memset(F, -0x7f7f7f, sizeof(F));
	memset(J, 0x7f7f7f, sizeof(J));

	for (int i = 1; i <= 2*n; i++) 
	{
		F[i][i] = line[i];
		J[i][i] = line[i];
	}

	for (int len = 1; len <= 2*n; len++) 
	{
		for (int l = 1; l <= 2*n - len + 1; l++) 
		{
			int r = l + len - 1;
			for (int k = l; k <= r-1; k++) 
			{
				if(t[k+1] == 'x')
				{
					F[l][r] = std::max(F[l][r],
								std::max(
									std::max(F[l][k]*F[k+1][r], J[l][k]*J[k+1][r]),
									std::max(F[l][k]*J[k+1][r], J[l][k]*F[k+1][r])
								)
							);
					J[l][r] = std::min(J[l][r],
								std::min(
									std::min(F[l][k]*F[k+1][r], J[l][k]*J[k+1][r]),
									std::min(F[l][k]*J[k+1][r], J[l][k]*F[k+1][r])
								)
							);
				}
				else
				{
					F[l][r] = std::max(F[l][r], F[l][k] + F[k+1][r]);
					J[l][r] = std::min(J[l][r], J[l][k] + J[k+1][r]);
				}
			}
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) 
		ans = std::max(ans, F[i][i+n-1]);
	printf("%d\n", ans);
	for (int i = 1; i <= n; i++) 
		if(F[i][i+n-1] == ans)
			printf("%d ", i);

	return 0;
}
